<!doctype html>
<html lang="en">
<head>
    <!-- Required meta tags -->
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <title>个人信息</title>

    <!-- === CSS === -->
    <link rel="stylesheet" href="bootstrap-4.0.0-beta/css/bootstrap.min.css">
    <link rel="stylesheet" href="css/ionicons.css">
    <link rel="stylesheet" href="css/now-ui-kit.css">
    <link rel="stylesheet" href="css/app.css">
</head>
<body onload="check();getMes()">
<!--=== navbar ===-->
<header class="header">
    <nav class="navbar navbar-expand-sm">
        <div class="container">
            <a class="navbar-brand" href="index.html">EShop</a>
            <button class="navbar-toggler navbar-toggler" type="button" data-toggle="collapse" data-target="#example-navbar" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
                <span class="navbar-toggler-bar bar1"></span>
                <span class="navbar-toggler-bar bar2"></span>
                <span class="navbar-toggler-bar bar3"></span>
            </button>
            <div class="collapse navbar-collapse" id="example-navbar" data-nav-image="assets/img/blurred-image-1.jpg">
                <ul class="navbar-nav">
                    <li class="nav-item">
                        <a class="nav-link" href="index.html">首页</a>
                    </li>
                    <li class="nav-item active dropdown">
                        <a class="nav-link dropdown-toggle" href="http://localhost" id="navbarDropdownMenuLink1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">商城</a>
                        <div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
                            <a class="dropdown-item" href="books.html">纸质书</a>
                            <a class="dropdown-item" href="book.html">电子书</a>
                        </div>
                    </li>
                    <li class="nav-item dropdown">
                        <a class="nav-link dropdown-toggle" href="http://example.com" id="navbarDropdownMenuLink" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">用户</a>
                        <div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
                            <a class="dropdown-item" onclick="check()" href="#" id="login">登陆</a>
                            <a class="dropdown-item" href="cart.html" id="cart">购物车</a>
                            <a class="dropdown-item" href="order.html" id="order">订单管理</a>
                        </div>
                    </li>
                </ul>
            </div>
        </div>
    </nav>
</header>
    <!--=== home 3 ===-->
    <section id="home-3" class="header-intro-1 d-flex align-items-center">
        <div class="container">
            <div class="row">
                <div class="col-12">
                    <div class="header-intro-wrap">
                        <div class="header-intro-title"><h1>个 人 信 息</h1></div>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <section>
        <div class="row">
            <div class="col-1"></div>
            <div class="col-2" id="image">头像</div>
            <div class="justify-content-start" id="username">用户名</div>
        </div>
        <br><br>
        <div class="row">
            <div class="col-2"></div>
            <div class="col-2" id="sex">性别</div>
            <div class="col-3" id="birthday">出生日期</div>
        </div>
    </section>

    <!--=== footer ===-->
    <section class="footer">
        <div class="container">
            <div class="row">
                <div class="col-12">
                    <div class="footer-wrap text-center">
                        <div class="footer-tag">All rights Reserved EwenTsai</div>
                    </div>
                </div>
            </div>
        </div>
    </section>
    
    <script>
        //从后端获取个人数据
        function getMes() {
            //创建ajax对象
            var ajax;
            if (window.XMLHttpRequest)
            {
                //  IE7+, Firefox, Chrome, Opera, Safari 浏览器执行代码
                ajax=new XMLHttpRequest();
            }
            else
            {
                // IE6, IE5 浏览器执行代码
                ajax=new ActiveXObject("Microsoft.XMLHTTP");
            }
            ajax.onreadystatechange = function () {
                if(ajax.readyState===4 && ajax.status===200){

                    var image = document.getElementById("image");
                    var username = document.getElementById("username");
                    var birthday = document.getElementById("birthday");

                    var jsonObj = eval('('+ajax.responseText+')');

                    image.innerHTML = jsonObj.imageAdress;
                    username.innerHTML = "用户名："+jsonObj.uname;
                    birthday.innerHTML = "出生日期："+jsonObj.birthday;
                }
            }
            ajax.open("get","/BTS/check.do?uid="+getCookie("uid"));
            ajax.send(null);
        }
    </script>
    <!-- ==== js ==== -->
    <script src="js/jquery-3.2.1.slim.min.js"></script>
    <script src="js/popper.min.js"></script>
    <script src="bootstrap-4.0.0-beta/js/bootstrap.min.js"></script>
    <script src="js/app.js"></script>
    <script src="js/util.js"></script>
</body>
</html>